import { Component } from 'react';
import { withRouter } from 'umi';
import { Helmet } from 'react-helmet';
import { siteName } from 'config';
import { connect } from 'dva';
import NProgress from 'nprogress';
import PrimaryLayout from './primaryLayout';
import { Layout, Row, Col } from 'antd';

import {
    PhoneOutlined, MailOutlined, EnvironmentOutlined, ApartmentOutlined, CopyrightOutlined,
    SecurityScanOutlined,
} from '@ant-design/icons';
const { pathToRegexp } = require("path-to-regexp")
const { Footer } = Layout;
@withRouter
@connect(({ loading }) => ({
    loading
}))
class BasicLayout extends Component {
    previousPath = ''

    constructor(props) {
        super(props)
    }

    render() {

        const { loading, location, children } = this.props

        // const currentPath = location.pathname + location.search
        const currentPath = location.pathname
        // console.log("current path" + currentPath);
        if (currentPath !== this.previousPath) {
            NProgress.start()
        }
        if (!loading.global) {
            NProgress.done()
            this.previousPath = currentPath
        }
        return <>
            <Helmet>
                <title>{siteName}</title>
                <meta name="viewport" content="width=device-width, initial-scale=1.0"></meta>
                <link rel="icon" href="/image/logo.png" type="image/x-icon" />
                <link rel="shortcut icon" href="/image/logo.png" type="image/x-icon" />
            </Helmet>
            <Layout >
                <PrimaryLayout>{children}</PrimaryLayout>
                <Footer style={{ background: '#005CBB', minHeight: '11vh' }} >
                    <Row justify={'space-around'} align={'middle'} style={{ color: 'white' }}>
                        <Col offset={3}></Col>
                        <Col>
                            <div><PhoneOutlined />联系电话：027-12345678</div>
                            <div><MailOutlined />邮箱：abc@efg.com</div>
                        </Col>
                        <Col>
                            <div><ApartmentOutlined />邮政编码：123456</div>
                            <div><EnvironmentOutlined />地址：武汉市江汉区XXXXX</div>
                        </Col>
                        <Col >
                            <div><SecurityScanOutlined />备案信息：...</div>
                            <div>版权所有<CopyrightOutlined />武汉XXXX有限公司</div>
                        </Col>
                        <Col span={2} />
                    </Row>
                </Footer>
            </Layout>

        </>
    }
}

export default BasicLayout;